﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;
using DLV.Library.Utilities;

namespace DLV.Data.Entities
{
    public class MenuController
    {
        public int InsertMenu(MenuInfo info)
        {
            return SQL.InsertMenu(info.RestaurantId, info.MenuTypeId, info.Viands, info.MenuName, info.SortDescription, info.DetailDescription, info.Price, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void UpdateMenu(MenuInfo info)
        {
            SQL.UpdateMenu(info.MenuId, info.RestaurantId, info.MenuTypeId, info.Viands, info.MenuName, info.SortDescription, info.DetailDescription, info.Price, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void DeleteMenu(MenuInfo info)
        {
            DeleteMenu(info.MenuId);
        }
        public void DeleteMenu(int menuId)
        {
            SQL.DeleteMenu(menuId);
        }
        public MenuInfo GetMenu(int menuId)
        {
            return CBO.FillObject<MenuInfo>(SQL.GetMenu(menuId));
        }
        public List<MenuInfo> ListMenu()
        {
            return CBO.FillCollection<MenuInfo>(SQL.ListMenu());
        }
        public List<MenuInfo> ListMenuByRestaurantAndMenuType(int restaurantId, int menuTypeId)
        {
            return CBO.FillCollection<MenuInfo>(SQL.ListMenuByRestaurantAndMenuType(restaurantId, menuTypeId));
        }
       
        public DataTable SelectMenu()
        {
            return CBO.ConvertToDataTable(ListMenu(), typeof(MenuInfo));
        }
        public Dictionary<object, object> ListMenuLookup()
        {
            var users = ListMenu().Where(p => p.Status == (int)Globals.DocumentStatus.Use).OrderBy(p => p.MenuName);
            var dicusers = new Dictionary<object, object>();

            foreach (MenuInfo info in users)
            {

                dicusers.Add(info.MenuId, info.MenuName);
            }
            return dicusers;
        }
    }
}
